import request from '_c/utils/request'

/**
 *  获取默认地址
 */
export function getDefaultAddress() {
	return request({
		url: '/api/shop/getDefaultAddre',
		method: 'GET'
	})
}

/**
 *  获取所有默认地址
 */
export function getAllAddress() {
	return request({
		url: '/api/shop/getAllAddre',
		method: 'GET'
	})
}

/**
 *  新增/修改地址
 */
export function saveOrUpdate(data) {
	if (!data.addressId) {
		return request({
			url: '/api/shop/saveAddress',
			method: 'POST',
			data
		})
	} else {
		return request({
			url: '/api/shop/updateAddress',
			method: 'PUT',
			data
		})
	}
}

/**
 * 根据id查询
 * @param addressId
 */
export function getById(addressId) {
	return request({
		url: '/api/shop/getDefaultAddre/' + addressId,
		method: 'GET'
	})
}

/**
 * 删除地址
 * @param addressId
 */
export function deletebyId(addressId) {
	return request({
		url: '/api/shop/deletebyId/' + addressId,
		method: 'DELETE'
	})
}


